<?php
session_start();
include ("dbConfig.php");
?>
<html>
<head>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js'></script>
<script src="js/main.js" type="text/javascript"></script>
<title>EduProcrasWebsiteLayout</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.centre {
	text-align: center;
	color: #FFF;
}
.centre div #Table_01 tr td p {
	font-family: Verdana, Geneva, sans-serif;
}

h1 {
	font-family: "BankGothic Lt BT", Geneva;
	font-size: 40px;
	color: #FFF;
}

</style>
<script type="text/javascript">
function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
</script>
<link href="css/scrolltotop.css" rel="stylesheet" type="text/css">
<link href="css/loginStatus.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#0000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" class="centre" onLoad="MM_preloadImages('images/btn_picsOn.gif','images/btn_videoOn.gif','images/btn_factsOn.gif','images/btn_aboutOn.gif','images/btnLogin_On.jpg')">

<a href="#" class="scrollToTop"></a>
<div>
<table id="Table_01" width="1025" height="769" border="0" cellpadding="0" cellspacing="0" align="center">
	<tr>
		<td>
			<img src="images/EduProcrasWebsiteLayout_01.gif" width="4" height="5" alt=""></td>
		<td>
			<img src="images/EduProcrasWebsiteLayout_02.gif" width="187" height="5" alt=""></td>
		<td colspan="9" rowspan="2">
			<img src="images/EduProcrasWebsiteLayout_03.gif" width="833" height="25" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="5" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/EduProcrasWebsiteLayout_04.gif" width="4" height="20" alt=""></td>
		<td rowspan="3"><a href="index.php"><img src="images/img_logo.gif" width="187" height="181" alt="" border="0"></a></td>
		<td>
			<img src="images/spacer.gif" width="1" height="20" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/EduProcrasWebsiteLayout_06.gif" width="4" height="145" alt=""></td>
		<td>
			<img src="images/EduProcrasWebsiteLayout_07.gif" width="9" height="145" alt=""></td>
		<td colspan="6">
			<img src="images/img_animatedHeader.gif" width="760" height="145" alt=""></td>
		<td colspan="2">
			<img src="images/EduProcrasWebsiteLayout_09.gif" width="64" height="145" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="145" alt=""></td>
	</tr>
	<tr>
		<td rowspan="2">
			<img src="images/EduProcrasWebsiteLayout_10.gif" width="4" height="25" alt=""></td>
		<td colspan="9" rowspan="2">
			<img src="images/EduProcrasWebsiteLayout_11.gif" width="833" height="25" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="16" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/EduProcrasWebsiteLayout_12.gif" width="187" height="9" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="9" alt=""></td>
	</tr>
	<tr>
		<td colspan="4">
<img src="images/EduProcrasWebsiteLayout_13.gif" width="70" height="63" alt=""><a href="login.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image38','','images/btnLogin_On.jpg',1)"><img src="images/btn_LoginOff.jpg" alt="Login" name="Image38" width="141" height="63" border="0"></a></td>
		<td><a href="pics.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_pics','','images/btn_picsOn.gif',1)"><img src="images/btn_picsOff.gif" alt="Pics" name="btn_pics" width="141" height="63" border="0"></a></td>
		<td><a href="video.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_video','','images/btn_videoOn.gif',1)"><img src="images/btn_videoOff.gif" alt="Videos" name="btn_video" width="141" height="63" border="0"></a></td>
		<td><a href="facts.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_facts','','images/btn_factsOn.gif',1)"><img src="images/btn_factsOff.gif" alt="Facts" name="btn_facts" width="142" height="63" border="0"></a></td>
		<td>
			<img src="images/EduProcrasWebsiteLayout_17.gif" width="3" height="63" alt=""></td>
		<td colspan="2"><a href="about.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('btn_about','','images/btn_aboutOn.gif',1)"><img src="images/btn_aboutOff.gif" alt="About" name="btn_about" width="138" height="63" border="0"></a></td>
		<td>
			<img src="images/EduProcrasWebsiteLayout_19.gif" width="57" height="63" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="1" height="63" alt=""></td>
	</tr>
	<tr>
		<td colspan="11">
        <div id="loginStatus" style="position: absolute; top: 0; left: 0; width: 500px;">
         <?php
		if ($_SESSION["access"] == 'granted'){
			?>
            <p1>Logged in. </p1><a href="userLogout.php">
			<p1>Logout</p1>
			</a>
            <?php
			include ("upload.php");
		}
		else{
		?>
        <p1>Not logged in!</p1>
        <?php
		}
		?>
        </div>
        <div id="content">
        <p>&nbsp;</p>
        <p>Welcome to Education Procrastination dot com!</p>
	    <p>Want to waste some time? Would you rather be doing anything other than work? So would we!</p>
	    <p>&nbsp;</p>
	    <p>New this week:</p>
 	    <p>New pics - Added 11/05/2012</p>
 	    <p>New videos - Added 11/05/2012</p>
 	    <p>New facts - Added 11/05/2012</p>
 	    <p>&nbsp;</p>
 	    <p>Note for those uploading files:</p>
	    <p>- Upload videos as an embedded link from YouTube through a text file.</p>
        <p><i>eg: "http://www.youtube.com/embed/VIDEO_ID"</i></p>
	    <p>- Upload facts as a text file.</p>
	    <p>- Upload images in .jpg, .gif, or .bmp format.</p>
		<br/>
             <a href="javascript:toggleLayer('page-wrap');" title="Latest Content">
<h1>Latest Content</h1>
</a>
	<div id="page-wrap">
    <br/>
        <p>Latest Pic:</p>
        <?php
        $sql = "SELECT link FROM 'UPLOADPICS' ORDER BY rowid ASC";
		foreach ($dbhandle->query($sql) as $row){
					$latestPic = $row['link'];
					?>
                    <?php
				}
				?>
                <img src="<?php echo $latestPic ?>" />
		<br/>
        <br/>
        <br/>
        <br/>
        <p>Latest Video:</p>
        <?php
        $sql = "SELECT link FROM 'UPLOADVIDS' ORDER BY rowid ASC";
		foreach ($dbhandle->query($sql) as $row){
					$latestVid = $row['link'];
					
					$fh = fopen($latestVid, 'r');
					$videoData = fgets($fh);
					fclose($fh);
				}
				?>
                <iframe width="420" height="315" src="<?php echo $videoData ?>" frameborder="0" allowfullscreen></iframe>
       	<br/>
        <br/>
        <p>Latest Fact:</p>
        <?php
        $sql = "SELECT link FROM 'UPLOADFACTS' ORDER BY rowid ASC";
		foreach ($dbhandle->query($sql) as $row){
					$latestFact = $row['link'];
					
					$fh = fopen($latestFact, 'r');
					$factData = fgets($fh);
					fclose($fh);
				}
				?>
                <p><?php echo $factData ?></p>
         <br/>
        <br/>
        <br/>
        <br/>   
     </div>
     
	    <p>&nbsp;</p>
        </div>
        </head>
        
<div id ='addContent'>
<?php

$doc = new DOMDocument();
$rootElement = $doc->appendChild($doc->createElement("latestContent"));

$latestPicElement = $rootElement->appendChild($doc->createElement("latestpic"));
$latestPicElement->appendChild($doc->createElement("item", "Latest Pic"));
$latestPicElement->appendChild($doc->createElement("content", $latestPic));

$latestVidElement = $rootElement->appendChild($doc->createElement("latestvideo"));
$latestVidElement->appendChild($doc->createElement("item", "Latest Video"));
$latestVidElement->appendChild($doc->createElement("content", $videoData));

$latestFactElement = $rootElement->appendChild($doc->createElement("latestfact"));
$latestFactElement->appendChild($doc->createElement("item", "Latest Fact"));
$latestFactElement->appendChild($doc->createElement("content", $factData));

$doc->save("xml/latestContent.xml");
?> 

</div>
<link rel="stylesheet" type="text/css" media="all" href="css/style.css" class="showContent" />
<div id="showContent">
	<script type="text/javascript"  src="js/jquery.js" ></script>
<title>Latest Content</title>
     <script>
     	$(document).ready(function(){
			$.ajax({
				type: "GET",
				url: "xml/sites.xml",
				dataType: "xml",
				success: function(xml) {
					$(xml).find('site').each(function(){
						var id = $(this).attr('id');
						var title = $(this).find('title').text();
						var url = $(this).find('url').text();
						$('<div class="items" id="link_'+id+'"></div>').html('<a href="'+url+'">'+title+'</a>').appendTo('#page-wrap');
						$(this).find('desc').each(function(){
							var brief = $(this).find('brief').text();
							var long = $(this).find('long').text();
							$('<div class="brief"></div>').html(brief).appendTo('#link_'+id);
							$('<div class="long"></div>').html(long).appendTo('#link_'+id);
						});
					});
				}
			});
		});
     </script>
</div>
        </div>
        <br/>
        <br/>
        </td>
		<td>
			<img src="images/spacer.gif" width="1" height="510" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/spacer.gif" width="4" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="187" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="9" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="202" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="141" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="141" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="142" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="3" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="131" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="7" height="1" alt=""></td>
		<td>
			<img src="images/spacer.gif" width="57" height="1" alt=""></td>
		<td></td>
	</tr>
</table>
</div>
<!-- End ImageReady Slices -->
</body>
</html>